#include "notifyonlinestatusnotification.h"
#include "account/accountbuddy.h"


namespace Notify {

OnlineStatusNotification::OnlineStatusNotification(Account::Buddy *buddy, QObject *parent) :
    Notification(parent),
    m_buddy(buddy)
{

}


OnlineStatusNotification::~OnlineStatusNotification()
{
    m_buddy.clear();
}


Notification::NotificationType OnlineStatusNotification::notificationType() const
{
    return Notification::OnlineStatusNotificationType;
}


QString OnlineStatusNotification::senderName() const
{
    if (m_buddy == NULL)
        return QString("");

    return m_buddy->displayName();
}


Account::Buddy *OnlineStatusNotification::sender() const
{
    if (m_buddy == NULL)
        return NULL;

    return m_buddy.data();
}


QString OnlineStatusNotification::text() const
{
    if (m_buddy == NULL)
        return QString("");

    if (m_buddy->onlineStatus() == true)
        return QString("has appeared online");

    return QString("has gone offline");
}


QString OnlineStatusNotification::avatar() const
{
    if (m_buddy == NULL)
        return QString ("");

    return m_buddy->avatarUrl();
}


QPixmap OnlineStatusNotification::avatarPixmap() const
{
    if (m_buddy == NULL)
        return m_defaultAvatarPixmap;

    return m_buddy->pixmap();
}


bool OnlineStatusNotification::onlineStatus() const
{
    if (m_buddy == NULL)
        return false;

    return m_buddy->onlineStatus();
}

} // namespace Notify
